package cn.kgc.springboot.vue.controller;

import cn.kgc.springboot.vue.commons.QueryCondition;
import cn.kgc.springboot.vue.entity.LogInfo;
import cn.kgc.springboot.vue.response.ResponseResult;
import cn.kgc.springboot.vue.service.LogInfoService;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;

/**
 * @author 课工场
 * @date 2024/12/31
 * @description
 */
@RestController
@RequestMapping("logs")
public class LogInfoController {

    @Resource
    private LogInfoService logInfoService;

    // 分页
    @PostMapping("page")
    public ResponseResult logsPage(@RequestBody QueryCondition<LogInfo> queryCondition){
        return logInfoService.logsPage(queryCondition);
    }


    // 批量删除
    @DeleteMapping("delete")
    public ResponseResult deleteLogs(@RequestBody List<Integer> ids){

        logInfoService.removeByIds(ids);

        return  ResponseResult.success();
    }
    // 导出日志
    @PostMapping("export")
    public void exportLogs(@RequestBody HashMap<String,String> params, HttpServletResponse response){

        logInfoService.exportLogs(params,response);
    }

}
